<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

<#include "../../common/header.html">

</head>
<body class="hold-transition skin-blue sidebar-mini">
	<div class="wrapper">
		<!-- 	顶部和左侧菜单的jsp s -->
		<#include "../../common/menu.html">
		<!-- 	顶部和左侧菜单的jsp e -->

		<!-- Content Wrapper. Contains page content -->
		<div class="content-wrapper">
			<!-- Content Header (Page header) -->
			<section class="content-header">
				<h1>用户转赠记录列表</h1>
			</section>

			<section class="content-header condition clearfix ">
				<form action="#" id="fromCondition">
					<div class="form-group">
         				<label>卡片类型:</label>
        			    <select class="form-control select2" style="width: 100%;" name="search_EQ_LONG_targetCardType">
           	  			<option selected="selected" value="">全部</option>
           	  				<#list sourceCardTypeMap?keys as key>  
               					<option value="${key}">${sourceCardTypeMap[key]!}</option>
        	  				</#list>  
          				</select>
    				</div> 	
    				<div class="form-group">
         				<label>方式:</label>
        			    <select class="form-control select2" style="width: 100%;" name="exchangeOrTransfer">
           	  			<option selected="selected" value="">全部</option>
           	  			<option  value="1">领卡</option>
           	  			<option  value="2">转赠</option>
           	  			<option  value="3">兑换</option>	
          				</select>
    				</div> 	
    				<div class="form-group">
						<label>卡片名称:</label> 
						<input type="text" class="form-control" name="search_LK_STRING_cardName">
					</div>	
					<div class="form-group">
						<label>批次:</label> 
						<input type="text" class="form-control" name="search_EQ_LONG_batch">
					</div>		
					<div class="form-group">
						<label>赠送人昵称:</label> 
						<input type="text" class="form-control" name="search_LK_STRING_sourceUserNickname">
					</div>
					<div class="form-group">
						<label>赠送人电话:</label> 
						<input type="text" class="form-control" name="search_LK_STRING_sourceUserPhone">
					</div>
					<div class="form-group">
						<label>赠送人卡号:</label> 
						<input type="text" class="form-control" name="search_LK_STRING_sourceCardNumber">
					</div>
					<div class="form-group">
						<label>接收人昵称:</label> 
						<input type="text" class="form-control" name="search_LK_STRING_receiverNickname">
					</div>
					<div class="form-group">
						<label>接收人电话:</label> 
						<input type="text" class="form-control" name="search_LK_STRING_receiverPhone">
					</div>
					<div class="form-group">
						<label>接收人卡号:</label> 
						<input type="text" class="form-control" name="search_LK_STRING_userCardNumber">
					</div>
					<div class="form-group">
						<label>赠送时间:</label>
						<div class="input-group">
							<div class="input-group-addon">
								<i class="fa fa-calendar"></i>
							</div>
							<input type="text" class="form-control pull-right daterange" name="search_DATERANGE_STRING_createTime"/>
						</div>
						<!-- /.input group -->
					</div>
					<!-- /.form group -->
					<div class="form-group"
						style="margin-top: 28px; margin-left: 15px;">
						<input type="submit" value="查询" id="submit"/>
						<input type="reset" value="清空" id="reset" />
					</div>
				</form>
			</section>

			<!-- Main content -->
			<section class="content" style="padding-bottom: 0px;">
				<div class="row">
					<div class="col-xs-12">
						<div class="box">
							<!-- /.box-header -->
							<div class="box-body">
								<table id="dataTable" class="table table-bordered table-striped" style="width:1700px">
									<thead id="thead1">
										<tr>
											<th>选择</th>
											<th excel='true'>卡片名称</th>
											<th excel='true'>卡片类型</th>
											<th excel='true'>批次</th>
											<th excel='true'>赠送人卡号</th>
											<th excel='true'>赠送人昵称</th>
											<th excel='true'>方式</th>
											<th excel='true'>赠送人电话</th>
											<th excel='true'>接收人昵称</th>
											<th excel='true'>接收人电话</th>
											<th excel='true'>接收人卡号</th>
											<th excel='true'>状态</th>
											<th excel='true'>赠送时间</th>
											<th excel='true'>有效期至</th>																			
										</tr>
									</thead>
								</table>
							</div>
							<!-- /.box-body -->
						</div>
						<!-- /.box -->
					</div>
					<!-- /.col -->
				</div>
				<!-- /.row -->
			</section>
			<!-- /.content -->
			<section class="content-header condition clearfix " style="padding: 0px 14px">
				<button onclick="exportExcel();" class="btn btn-default" style="margin-right: 10px">导出excel</button>
			</section>
						
			 <#include "../../common/errorMsg.html">
		</div>

	</div>
	<!-- ./wrapper -->
</body>
<script>
 /*  存放选中行的id的数组 */
  var selected = [];
  
  //adminlte表格的对象
  var datatable = null;
  var formValidator = null;
  
  $(function () {
		    
	   var vm = new Vue({
	 		 el: '#fromCondition',
		    methods: {
		    	submitForm: function () {
				  	datatable.draw();
				  	//每次重画后,清空选中的记录
		    		selected.splice(0,selected.length)
		    	}
      	  }
  	  })
	   
	   //校验器
		  formValidator = $("#fromCondition").validate({
				onkeyup : false,
				focusInvalid : false,  //错误时,错误选项不会得到焦点
				focusCleanup : true,   //得到焦点时，清空错误提示信息
				submitHandler : function() { //表单提交句柄,为一回调函数，带一个参数：form
					vm.submitForm();
				},
				rules : {
					search_EQ_LONG_cardId:{
						digits:true
					}
				},
				messages : {
					search_EQ_LONG_cardId:{
						digits:"只能输入数字"
					}
				}
		  });
	          
      datatable = $('#dataTable').DataTable({
           'paging'      : true,
           'lengthChange': true,
           'searching'   : false,
           'ordering'    : true,
           'info'        : true,
           'autoWidth'   : false,
           "scrollX"	 : true,
           "scrollY"	 : true ,  
           "processing"	 : true,
           "serverSide"	 : true,
           "order": [[ 0, 'desc' ]],
           "pagingType": "full_numbers",
           "language": {
               "lengthMenu":   "显示 _MENU_ 条记录",
               "zeroRecords":  "没有符合条件的记录",
               "info":         "第 _PAGE_ 页,共 _PAGES_ 页",
               "infoEmpty":    "没有符合条件的记录",
               "paginate": {
            	   "first":     "第一页",
            	   "next":      "下一页",
            	   "previous":  "上一页",
            	   "last":      "最后一页"
                }           	  
           },
           //如果查询条件有校验，需要加这个
           "preDrawCallback": function( settings ) {
        	   if(!isEmpty(formValidator)) {
        		   if(!formValidator.valid()) {
            		   return false;
            	   }
        	   }        	
        	},
           "drawCallback": function( settings ) {
        	   //每次重画后,清空选中的记录
	    		selected.splice(0, selected.length);
           },
           "ajax": {
               "url": "/hicatcard/userCardTransfer/getUserCardTransferListData",
               "type": "POST",
               "data": function ( d ) {
            	  var formData = $("#fromCondition").serializeJson();
            	  for(var obj in formData)  {
            		  d[obj+""] = formData[obj];
            	  }
               }
           },
           "columns": [     
                      { "data": "userCardTransferId", "orderable": false,"render":function(data, type, full, meta) {
           	            	   return  '<input type="checkbox" value="' + data + '">';
           	          }},        
                      { "data": "cardName" },      
                      { "data": "targetCardType",
        	            	"render": function ( data, type, full, meta ) {     
        		           		<#list sourceCardTypeMap?keys as key>
        		         			if(data == '${key}') {
        		         				return '${sourceCardTypeMap[key]!}';
        		   					}
        						</#list>
        	  		  }},
        	  		  { "data": "batch" },      
                      { "data": "sourceCardNumber" },
                      { "data": "sourceUserNickname" },
                      { "data": "exchangeOrTransfer" },
                      { "data": "sourceUserPhone" },
                      { "data": "receiverNickname" },
                     	  		  	  
      	  		      { "data": "receiverPhone" },
                  	  { "data": "userCardNumber" },
                  	  { "data": "receiverStatus",
      	            	"render": function ( data, type, full, meta ) {     
      		           		<#list statusMap?keys as key>
      		         			if(data == '${key}') {
      		         				return '${statusMap[key]!}';
      		   					}
      						</#list>
      	  		      }},	  
                      { "data": "createTime"},
                      { "data": "receiverEndTime"}
                      
                                     	 
       			]
         })
});
 
//查看信息
function toUserCardServiceListPage(userCardId){
	
	window.location.href="/hicatcard/userCardService/toListPage?search_EQ_LONG_userCardId=" + userCardId;
	
}

//查看转赠情况
function checkDonation(userCardId) {
	window.location.href="/hicatcard/userCard/toCheckDonationPage?userCardId=" + userCardId;
}

</script>
<script src="${resurcePath}/cloudpay/js/common/dataTable.js"></script>
<script src="${resurcePath}/cloudpay/js/common/exportexcel.js"></script>
</html>

